namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class UpdateKaoHeFanWei : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.KaoHeFanWeiKeShis", "keShi_ksid", "dbo.KeShis");
            DropForeignKey("dbo.NeiRongs", "KaoHeFanWeiKeShi_khfwksi", "dbo.KaoHeFanWeiKeShis");
            DropForeignKey("dbo.KaoHeFanWeiKeShis", "KaoHeFanWei_khfwid", "dbo.KaoHeFanWeis");
            DropIndex("dbo.NeiRongs", new[] { "KaoHeFanWeiKeShi_khfwksi" });
            DropIndex("dbo.KaoHeFanWeiKeShis", new[] { "keShi_ksid" });
            DropIndex("dbo.KaoHeFanWeiKeShis", new[] { "KaoHeFanWei_khfwid" });
            AddColumn("dbo.ZhiWeis", "KaoHeFanWei_khfwid", c => c.Int());
            AddColumn("dbo.KaoHeFanWeis", "NeiRong_nrid", c => c.Int());
            CreateIndex("dbo.ZhiWeis", "KaoHeFanWei_khfwid");
            CreateIndex("dbo.KaoHeFanWeis", "NeiRong_nrid");
            AddForeignKey("dbo.KaoHeFanWeis", "NeiRong_nrid", "dbo.NeiRongs", "nrid");
            AddForeignKey("dbo.ZhiWeis", "KaoHeFanWei_khfwid", "dbo.KaoHeFanWeis", "khfwid");
            DropColumn("dbo.NeiRongs", "KaoHeFanWeiKeShi_khfwksi");
            DropTable("dbo.KaoHeFanWeiKeShis");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.KaoHeFanWeiKeShis",
                c => new
                    {
                        khfwksi = c.Int(nullable: false, identity: true),
                        keShi_ksid = c.Int(),
                        KaoHeFanWei_khfwid = c.Int(),
                    })
                .PrimaryKey(t => t.khfwksi);
            
            AddColumn("dbo.NeiRongs", "KaoHeFanWeiKeShi_khfwksi", c => c.Int());
            DropForeignKey("dbo.ZhiWeis", "KaoHeFanWei_khfwid", "dbo.KaoHeFanWeis");
            DropForeignKey("dbo.KaoHeFanWeis", "NeiRong_nrid", "dbo.NeiRongs");
            DropIndex("dbo.KaoHeFanWeis", new[] { "NeiRong_nrid" });
            DropIndex("dbo.ZhiWeis", new[] { "KaoHeFanWei_khfwid" });
            DropColumn("dbo.KaoHeFanWeis", "NeiRong_nrid");
            DropColumn("dbo.ZhiWeis", "KaoHeFanWei_khfwid");
            CreateIndex("dbo.KaoHeFanWeiKeShis", "KaoHeFanWei_khfwid");
            CreateIndex("dbo.KaoHeFanWeiKeShis", "keShi_ksid");
            CreateIndex("dbo.NeiRongs", "KaoHeFanWeiKeShi_khfwksi");
            AddForeignKey("dbo.KaoHeFanWeiKeShis", "KaoHeFanWei_khfwid", "dbo.KaoHeFanWeis", "khfwid");
            AddForeignKey("dbo.NeiRongs", "KaoHeFanWeiKeShi_khfwksi", "dbo.KaoHeFanWeiKeShis", "khfwksi");
            AddForeignKey("dbo.KaoHeFanWeiKeShis", "keShi_ksid", "dbo.KeShis", "ksid");
        }
    }
}
